﻿<%@ Page Language="C#" %>
<script type="text/javascript">

 $(document).ready(function(){
   var eBayUserID='<%=Request["ebayuserid"]%>';
   var feedbackID='<%=Request["feedbackid"]%>';
   var index = '<%=Request["index"]%>';
   $('#ddv-'+index).find('[title="reason"]').combobox({
     width: 90,
     valueField: 'id',
     textField: 'text',
     data: [
       { id: 'IAD', text: '描述不符' },
       { id: 'DT', text: '发货时间' },
       { id: 'Communication', text: '沟通' },
       { id: 'P&P', text: '邮费与包裹费' }
     ],
     //value: ['IAD','DT'],
     multiple: true,
     panelHeight: 'auto'
   });
   
   $.getJSON(
     './MailHandler.ashx?act=q&id=0401&ebayuserid=' + eBayUserID + '&feedbackid=' + feedbackID + '&ts=' + new Date().getTime(),
     function (data) {
       if (data.retVal == 0) {
         if (data.retSrc && data.retSrc.Feedback && data.retSrc.Feedback.length > 0) {
           var feedback = data.retSrc.Feedback[0];
           var reasons = [];
           for (i in data.retSrc.Reasons) {
             reasons.push(data.retSrc.Reasons[i].Reason);
           }

           $('#ddv-' + index).find('[title="orderid"]').text(feedback.OrderID);
           $('#ddv-' + index).find('[title="buyerid"]').text(feedback.UserID);
           $('#ddv-' + index).find('[title="saledate"]').text(feedback.SaleDate);
           $('#ddv-' + index).find('[title="paidondate"]').text(feedback.PaidonDate);
           $('#ddv-' + index).find('[title="shippingdate"]').text(feedback.DispatchDate);
           $('#ddv-' + index).find('[title="feedbacktype"]').text(feedback.CommentType);
           $('#ddv-' + index).find('[title="feedbackdate"]').text(feedback.CommentTime);
           $('#ddv-' + index).find('[title="reason"]').combobox('setValues', reasons);
         }
       }
     });

   $('#ddv-' + index).find('[name="history"]').datagrid({
     url: '../../TableHanders.aspx?act=q&tid=8010&type=0',
     columns: [[
       { field: 'Date', title: '日期' },
       { field: 'Username', title: '发起人' },
       { field: 'Operation', title: '动作' },
       { field: 'Message', title: '留言' }
     ]],
     queryParams: { 'ebayuserid': eBayUserID, 'feedbackid': feedbackID }
   });

   $('#ddv-' + index).find('[title="btnleavemessage"]').click(function () {
       var content = $('#ddv-' + index).find('[title="txtresponse"]').val();
       var data = { 'eBayUserID': eBayUserID, 'FeedbackID': feedbackID, 'Body': content }
       $.post(
         './MailHandler.ashx?act=u&id=0115',
         data,
         function (jdata) {
             var data = $.parseJSON(jdata)
             if (data.retVal == 0) {
                 alert('保存成功');
             }
             else {
                 alert(data.retMsg);
             }
         });
   });

   $('#ddv-' + index).find('[title="btnresponse"]').click(function () {
       var content = $('#ddv-' + index).find('[title="txtresponse"]').val();
       var data = { 'eBayUserID': eBayUserID, 'FeedbackID': feedbackID, 'Body': content }
       $.post(
         './MailHandler.ashx?act=u&id=feedbackresponse',
         data,
         function (jdata) {
             var data = $.parseJSON(jdata)
             if (data.retVal == 0) {
                 alert('保存成功');
             }
             else {
                 alert(data.retMsg);
             }
         });
   });

   $('#ddv-' + index).find('[title="btncancelrequest"]').click(function () {
     $.getJSON(
       './MailHandler.ashx?act=u&id=cancelfeedback&ebayuserid=' + eBayUserID + '&feedbackid=' + feedbackID,
       function(data) {
         if (data.retVal == 0) {
             alert('设置成功');
         }
         else {
           alert(data.retMsg);
         }
       });
   });

   $('#ddv-' + index).find('[title="btnrejectrequest"]').click(function () {
       $.getJSON(
         './MailHandler.ashx?act=u&id=0110&ebayuserid=' + eBayUserID + '&feedbackid=' + feedbackID,
         function (data) {
             if (data.retVal == 0) {
                 alert('设置成功');
             }
             else {
                 alert(data.retMsg);
             }
         });
   });

   $('#ddv-' + index).find('[title="btnsave"]').click(function () {
       
   });

   $('#ddv-' + index).find('[title="btnSaveReason"]').click(function () {
       var reasons = $('#ddv-' + index).find('[title="reason"]').combobox('getValues');
       $.getJSON(
          './MailHandler.ashx?act=u&id=0119',
          { 'eBayUserID': eBayUserID, 'FeedbackID': feedbackID, 'Reasons': JSON.stringify(reasons) },
          function (data) {
              if (data.retVal == 0) {
                  alert('设置成功');
              }
              else {
                  alert(data.retMsg);
              }
          });
   });
 });
 
</script>
<div>
  <table>
    <tr>
      <td>订单号: <span title="orderid"></span></td>
      <td>Buyer ID: <span title="buyerid"></span></td>
    </tr>
    <tr>
      <td>销售时间: <span title="saledate"></span></td>
      <td>付款时间: <span title="paidondate"></span></td>
      <td>发货时间: <span title="shippingdate"></span></td>      
    </tr>
  </table>
  <hr />
  <table>
    <tr>
      <td>评价: <span title="feedbacktype"></span></td>
      <td>评价日期: <span title="feedbackdate"></span></td>
      <td>最近沟通日期: <span title="lastcommunicatedate"></span></td>
    </tr>
    <tr>
      <td>原因: <input name="reason" title="reason" class="easyui-combobox" /><a title="btnSaveReason" class="easyui-linkbutton">保存</a></td>
      <td>状态: <span title="status"></span></td>
      <td>节点日期: <span title="deadline"></span></td>
    </tr>
  </table>
  <hr />
  <table title="历史信息" name="history" style="height:120px"/>
  <hr />
  <div>
    <textarea title="txtresponse" style="width:100%" rows="5"></textarea>
  </div>
  <%--<input name="response" type="text" />--%>
  <div>
    <a title="btncancelrequest" class="easyui-linkbutton">发送撤销请求</a>
    <a title="btnrejectrequest" class="easyui-linkbutton">拒绝撤销</a>
    <a title="btnsave" class="easyui-linkbutton"  style="float:right">保存</a>
    <a title="btnresponse" class="easyui-linkbutton"  style="float:right">回复</a>
    <a title="btnleavemessage" class="easyui-linkbutton" style="float:right">留言</a>
  </div>
</div>

